home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-15 / phbench.zip / BENCHFN.C < prev    next >
Text File  |  1993-01-04  |  813b  |  26 lines

  1. /* benchfn - benchmark for function calls
  2.  * Thomas Plum, Plum Hall Inc, 609-927-3770
  3.  * Let  T  be the execution time in milliseconds
  4.  * Then  average time per operator  =  T/major  usec
  5.  * (Because the inner loop has exactly 1000 operations)
  6.  */
  7. #include <stdio.h>
  8. int dummy = 0;
  9.  
  10. f2() { f3();f3();f3();f3();f3();f3();f3();f3();f3();f3();} /* 10 */
  11. f1() { f2();f2();f2();f2();f2();f2();f2();f2();f2();f2();} /* 10 */
  12. f0() { f1();f1();f1();f1();f1();f1();f1();f1();f1();} /* 9 */
  13.  
  14. main(ac, av)
  15.         int ac;
  16.         char *av[];
  17.         {
  18.         long d, major, atol();
  19.  
  20.         major = atol(av[1]);
  21.         printf("executing %ld iterations\n", major);
  22.         for (d = 1; d <= major; ++d)
  23.                 f0(); /* executes 1000 calls */
  24.         printf("dummy=%d\n", dummy);
  25.         }
  26.